package com.cqhfan.interactionservice.task;

import com.cqhfan.interactionservice.config.LikedNotifyProperties;
import com.cqhfan.interactionservice.service.LikedRecordService;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 眭传洪
 * @create 2025-08-14 16:20
 */
@Component
public class LikedChangeNotifyTask {

    @Resource
    private LikedNotifyProperties likedNotifyProperties;

    @Resource
    private LikedRecordService likedRecordService;

    @Scheduled(fixedDelay = 20000)
    public void likedChangeHandler() {
        List<String> types = likedNotifyProperties.getTypes();
        Long handleNum = likedNotifyProperties.getHandleNum();
        // 处理点赞变更
        for (String type : types) {
            likedRecordService.handleLikesChange(type, handleNum);
        }
    }

}
